var InterValObj; //timer变量，控制时间
var count = 120; //间隔函数，1秒执行
var curCount;//当前剩余秒数
var code = ""; //验证码
var hashcode = ""; //hashCode校验码

/*var textbox = document.getElementById('birthday');

textbox.onfocus = function () {
    this.type = 'date';
    this.focus();
}*/

function submitForm(host, port) {
    var name=$("#name").val();
    var phone=$("#phone").val();
    var code = $("#code").val();
    var age = $("#age").val();
    var sex = $("#sex").val();
    var hashcode;

    if (typeof(Storage) !== "undefined"){
        hashcode = localStorage.getItem("hashcode");
    }

    if(name == ""){
        alert("名字不能为空");
    }else if(phone == ""){
        alert("电话号码不能为空");
    }else if(code == ""){
        alert("验证码无效");
    }else{
        $.ajax({
            type: "POST",
            dataType: "text", //数据格式:JSON
            url: '/marketing/potentialCustomerRollIn?code='+code+'&hashcode='+hashcode,
            contentType: 'application/json;charset=utf-8',
            data: '{"name": "'+ name + '", "phone": "' + phone + '", "sex": "' + sex + '", "age": "' + age + '"}',//目标地址
            error: function (XMLHttpRequest, textStatus, errorThrown) { },
            success: function (msg){
                var obj = JSON.parse(msg);
                if(obj.error_code == 0){
                    window.location.href = "http://" + host + ":" + port + "/marketing/thanks";
                }else {
                    alert(obj.error_message);
                }
            }
        });
    }
}